home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
THINKC
/
4_0
/
DONALDXC
/
GETCATAL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-05-01
|
3KB
|
110 lines
#include <MacTypes.h>
#include <OSUtil.h>
#include <MemoryMgr.h>
#include <FileMgr.h>
#include <ResourceMgr.h>
#include <pascal.h>
#include <hfs.h>
#include <string.h>
#include "HyperXCmd.h"
#include "HyperUtils.h"
/*** If you read this column ***/
/*** column on a regular basis ***/
/*** you may want to add these ***/
/*** routines to HyperUtils.c ***/
/*** ***/
/*** If you don't have Hyper- ***/
/*** utils.c, you can obtain it ***/
/*** from MacTutor for a small ***/
/*** handling charge ***/
#define SYNC 0
AppendCharToHandle( theHand, theChar )
Handle theHand;
char theChar;
/****************************
*
* Given a valid handle, append
* the character passed in to
* the end of the handle
*
* This is a useful way to embed
* \r, \t or \0 into a container
* for use by hypercard.
****************************/
{
long hsiz = GetHandleSize( theHand );
char *dirP;
SetHandleSize( theHand, hsiz + 1 );
dirP = *theHand + hsiz;
*dirP= theChar;
}
GetCatalog( wdref, dirH )
short wdref;
Handle dirH;
/****************************
* Get a listing of the directory
* passed in.
*
* In:
* wdref == reference number of the
* the desired working directory
*
* dirH == handle to the output container.
*
* Note that we allocate all structures
* in the heap to minimize the impact
* a high directory valence might have
* on the stack.
****************************/
{
OSErr done = 0; /* goes true when done searching */
CInfoPBPtr catPB = (CInfoPBPtr)NewPtr( sizeof(CInfoPBRec));
WDPBPtr wdPB = (WDPBPtr)NewPtr( sizeof(WDPBRec));
char *fname = (char *)NewPtr( 256L );
DebugStr("\pget cat");
if( catPB && wdPB && fname ){
catPB->dirInfo.ioNamePtr = (StringPtr)fname;
catPB->dirInfo.ioFDirIndex = 0;
catPB->dirInfo.ioVRefNum = wdref;
do{
*(catPB->dirInfo.ioNamePtr) = '\0';
catPB->dirInfo.ioFDirIndex++;
catPB->dirInfo.ioDrDirID = 0;
if( (done = PBGetCatInfo( catPB, SYNC ) ) == noErr ){
pStrToField( fname, '', dirH );
if( catPB->dirInfo.ioFlAttrib & 0x010 ){ /*** it's a directory ***/
AppendCharToHandle( dirH, ':' );
/*
wdPB->ioNamePtr = NIL;
wdPB->ioWDProcID = 0;
wdPB->ioWDVRefNum = catPB->dirInfo.ioVRefNum;
wdPB->ioWDDirID = catPB->dirInfo.ioDrDirID;
if( PBOpenWD( wdPB, SYNC) == noErr ){
GetCatalog( catPB->dirInfo.ioVRefNum, dirH);
PBCloseWD( wdPB, SYNC );
}
*/
}
AppendCharToHandle( dirH, '\r' );
}
}while( !done );
DisposPtr( (Ptr)catPB );
DisposPtr( (Ptr)wdPB );
DisposPtr( (Ptr)fname );
}
}